﻿using BLL;
using DAL;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace HoteCode.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RoomTypeController : ControllerBase
    {
        public RoomTypeBLL RoomTypeBLL { get; }
        

        public RoomTypeController(RoomTypeBLL roomTypeBLL)
        {
            RoomTypeBLL = roomTypeBLL;
            
        }
        [HttpPost]
        /// <summary>
        /// 房型添加
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public IActionResult RoomTypeAdd(RoomTypeModel info)
        {
            try
            {
                var res=RoomTypeBLL.RoomTypeAdd(info);
              
                return Ok(res);
            }
            catch (Exception)
            {
                
                throw;
            }
        }
        [HttpGet]
        /// <summary>
        /// 显示查询分页
        /// </summary>
        /// <param name="totalCount">页容量</param>
        /// <param name="totalPage">页码</param>
        /// <param name="Pageindex">当前页</param>
        /// <param name="PageSize">页码</param>
        /// <param name="RoomTypeName">房型名称</param>
        /// <param name="Asay">房型大小</param>
        /// <returns></returns>
        public IActionResult GetRoomTypesList( int Pageindex = 1, int PageSize = 2, string? RoomTypeName = "", int? max = null, int? min = null)
        {
            try
            {
                 int totalCount = 0; int totalPage = 0;
               var list= RoomTypeBLL.GetRoomTypesList(out totalCount, out totalPage, Pageindex, PageSize, RoomTypeName, max,min);
                return Ok(new
                {
                    list = list,
                    totalCount = totalCount,
                    totalPage = totalPage
                });
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
